using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityGameFramework.Runtime;
using GameFramework.Procedure;
using ProcedureOwner = GameFramework.Fsm.IFsm<GameFramework.Procedure.IProcedureManager>;
using GameFramework.Event;
using System;

public class Demo4_ProcedureMenu : ProcedureBase
{
    protected override void OnEnter(ProcedureOwner procedureOwner)
    {
        base.OnEnter(procedureOwner);

        Log.Debug("[Demo4_ProcedureMenu] OnEnter");

        EventComponent evt = UnityGameFramework.Runtime.GameEntry.GetComponent<EventComponent>();
        evt.Subscribe(OpenUIFormSuccessEventArgs.EventId, OnOpenUIFormsuccess);

        UIComponent ui = UnityGameFramework.Runtime.GameEntry.GetComponent<UIComponent>();

        ui.OpenUIForm("Assets/GameFrameworkDemo4/Demo4_UIForm.prefab", "DefaultGroup", this);
    }

    private void OnOpenUIFormsuccess(object sender, GameEventArgs e)
    {
        var ne = (OpenUIFormSuccessEventArgs)e;
        if(ne.UserData == this)
        {
            Log.Debug("[Demo4_ProcedureMenu] OnOpenUIFormsuccess UI Load Succ!");
        }
    }
}
